package com.hspedu.poly_.polyparameter;

public class Main {
    public static void main(String[] args) {
        Employee[] e = new Employee[3];
        e[0] = new Ordinary("小杨",3000,"端盘子");
        e[1] = new Manager("小王",6000,5000,"产品经理");
        e[2] = new Employee("小吴",9000);

        for (int i = 0; i < e.length ; i++) {
            showEmpAnnual(e[i]);
            testWork(e[i]);
            System.out.println();
        }
    }

    public static void showEmpAnnual(Employee e){
        System.out.println(e.getAnnual());
    }

    public static void testWork(Employee e){
        if(e instanceof Ordinary){
            ((Ordinary)e).work();//向下转型
        }else if (e instanceof Manager){
            ((Manager)e).manager();//向下转型
        }else if ( e instanceof  Employee){

        }else{
            System.out.println("类型错误，请检查类型");
        }
    }

}
